1. Field of the Invention
The invention relates to managing constants in memory, in particular for constants associated with data structures into memory.
2. Description of Related Art
Java is an object oriented programming language, which is often used in a network environment, for example, the Internet. Java's source code is written, and then the source code is compiled into a series of class files. The class files can be stored remotely, for example on a server and then be loaded dynamically when needed on a local system. The class files include bytecode, a set of instructions lower level than the original Java source code, yet higher level than code specific to a particular processor. This helps to allow Java to be particularly suited for the network environment, so that a variety of different local systems can run the Java programs from a network server. Java classes can be distributed to a variety of different systems, as may be connected to the Internet. For example, when encountering a Web page via a browser, a Java application may be initiated, which would involve the Java class files being loaded via the Internet on to the local system.
A local system that runs the Java classes needs functionality to interpret the Java bytecode. One system that provides such functionality is a Java Virtual Machine. The Java Virtual Machine loads the respective classes from the class files and executes methods as needed. The Java Virtual Machine is typically implemented in software, often associated with a browser, but may also be implemented in hardware.
In order to provide useful network applications to a wide variety of systems, it is desirable to be able to run Java applications on small systems that may not have a large amount of memory. Because such systems are small and may not possess excessive memory, it is helpful to conserve the use of memory used by the Java application, in particular the use of random access memory (read-write memory). One approach is to preload classes into memory, loading into read-only memory the methods and data that do not vary, while loading into random access memory varying data and methods. Such an approach is described in U.S. Pat. No. 5,815,718, entitled “Method And System For Loading Classes In Read-Only Memory,” invented by T. Tock, (hereinafter, “Tock”), which is incorporated herein by reference in its entirety. Classes in Java include typically a number of constants. These constants may require a significant amount of memory on the local system that is running the Java program. The Tock patent indicates that the offline class loader eliminates duplicate constants, in order to combine the constant pools of all the classes in a space efficient manner.
It would be desirable to provide a method and a system which overcome the deficiencies of the prior art.